﻿<?php

class CongTy_View{
	//var $arrData;
	
	function _construct($arr){
		//$this->arrData = $arr;
		
	}
	
	//hiển thị toàn bộ thông tin công ty
	function showAll_CongTy($arrData){		
		$naviCty = self::showMenu_Congty(0);
		$html = "<br/><center><table width='95%' border='none' cellpadding='5'>
			<tr>$naviCty</tr>
			<tr><td colspan='5'><hr/></td></tr>
			<tr><td colspan='2'><a href='index.php'>Về trang trước</a></td><td colspan='3'><center><b>DANH SÁCH CÔNG TY</b></center></td></tr>
			<tr align='center' class='bgFFE29C'>
				<td><b>Mã Cty </b></td>
				<td><b>San CK </b></td>
				<td><b>Thông tin <b></td>
				<td><b>Lên sàn </b></td>
				<td></td></tr>
			";
		$i=0;
		$cColor="";
		foreach($arrData as $field){
			$macty  = $field->MaCongTy;
			$sanck  = $field->SanCk;
			$tencty = $field->TenCongTy;
			$tenqt	= $field->TenQuocTe;
			$dc		= $field->DiaChi;
			$dt		= $field->DienThoai;
			$fax	= $field->Fax;
			$web	= $field->Website;
			switch($field->DaLenSan){
				case '0': $type = "Có";break;
				case '1': $type = "Không"; break;					
			}
			if($i%2==0)
				$cColor = "class='bgCBCAC1'";
			else
				$cColor="";
			$html .="<tr $cColor ><td><input class='textBold textCenter' type='text' id='MaCongTy' value='$macty' size='3' /></td>
					<td><input class='textCenter' type='text' id='SanCK' value='$sanck' size='5' /></td>
					<td> 
						<table width='100%'>
							<tr><td>Tên công ty</td><td>: $tencty </td></tr>
							<tr><td>Tên quốc tế</td><td>: $tenqt</td></tr>
							<tr><td>Địa chỉ</td><td>: $dc </td></tr>
							<tr><td>ĐIện thoại</td><td>: $dt</td></tr>
							<tr><td>Fax</td><td>: $fax</td></tr>
							<tr><td>Website</td><td>: $web</td></tr>
						</table>
					</td><td align='center'>$type</td>
					<td>
						<a href='".Consts::URL_SHOW_UPDATE_CTYTHONGTIN."&macty=$macty'>Sửa</a><br/> 
						<a href='javascript:showConfirm(\"$macty\")'>Xóa</a>
					</td></tr>
					<!--tr><td colspan='5'><hr/></td></tr-->";
			$i++;				
		}
		
		$html .= "<tr><td colspan='5'><center>1 | 2 | 3</center></td></tr>
			</table></center>";
		return $html;
	}
	
	//HIỂN THỊ THÔNG TIN CẦN UPDATE
	function showUpdate_CongTy($arrData){
		$naviCty = self::showMenu_Congty(1);
		$html = "<form method='post' name='".consts::FRM_UPDATE."' action='congty.php'>
		<br/><center><table width='95%' border='0' cellpadding='5'>
			<tr>$naviCty</tr>
			<tr><td colspan='5'><hr/></td></tr>
			<tr><td colspan='2'><a href='congty.php?ma=congtythongtin&act=view'>Về trang trước</a></td>
				<td colspan='3'><center><b>THÔNG TIN CÔNG TY</b></center></td></tr>
			
			<tr align='center' class='bgFFE29C'>
				<td><b>Mã Cty </b></td>
				<td><b>San CK </b></td>
				<td><b>Thông tin <b></td>
				<td><b>Lên sàn </b></td>
				<td></td></tr>";
		//foreach($this->arrData as $field){
			/*$macty  = $arrData->MaCongTy;
			$sanck  = $arrData->SanCk;
			$tencty = $arrData->TenCongTy;
			$tenqt	= $arrData->TenQuocTe;
			$dc		= $arrData->DiaChi;
			$dt		= $arrData->DienThoai;
			$fax	= $arrData->Fax;
			$web	= $arrData->Website;*/
			
			//var_dump(gettype($arrData));
			
			$macty  = $arrData['MaCongTy'];
			$sanck  = $arrData['SanCk'];
			$tencty = $arrData['TenCongTy'];
			$tenqt	= $arrData['TenQuocTe'];
			$dc		= $arrData['DiaChi'];
			$dt		= $arrData['DienThoai'];
			$fax	= $arrData['Fax'];
			$web	= $arrData['Website'];
			
			$nameRadio = Consts::LEN_SAN;
			$radioBtn = "";
			//switch($arrData->DaLenSan){
			switch($arrData['DaLenSan']){
				case '0': 					
					$radioBtn = "<input type='radio' name='$nameRadio' value='0' checked /> Có <br>
						 		<input type='radio' name='$nameRadio' value='1' /> Không";
					break;
				case '1': 					
					$radioBtn = "<input type='radio' name='$nameRadio' value='0' /> Có <br>
						 		<input type='radio' name='$nameRadio' value='1' checked /> Không";
					break;
			}
			

			$html .="<tr><td><input class='textBold textCenter' type='text' name='".Consts::MA_CTY."' value='$macty' size='3' /></td>
					<td><input class='textCenter' type='text' name='".Consts::SAN_CK."' value='$sanck' size='5' /></td>
					<td> 
						<table width='100%'>
							<tr><td>Tên công ty</td><td><input type='text' name='".ConstS::TEN_CTY."' value='$tencty' size='60' /> </td></tr>
							<tr><td>Tên quốc tế</td><td><input type='text' name='".Consts::TEN_QTE."' value='$tenqt' size='60' /></td></tr>
							<tr><td>Địa chỉ</td><td><input type='text' name='".Consts::DIA_CHI."' value='$dc' size='60' /></td></tr>
							<tr><td>ĐIện thoại</td><td><input type='text' name='".Consts::DIEN_THOAI."' value='$dt' size='50' /></td></tr>
							<tr><td>Fax</td><td><input type='text' name='".Consts::FAX."' value='$fax' size='50' /></td></tr>
							<tr><td>Website</td><td><input type='text' name='".Consts::WEB."' value='$web' size='50' /></td></tr>
						</table>
					</td>
					<td>$radioBtn</td>
					</tr>";
		//}
		
		$html .= "<tr><td colspan='4'><center><button name='".Consts::BTN_UPDATE."' type='submit' value='congtythongtin'>Cập nhật</button></center></td></tr>				
			</table></center>";
		$html .= self::showHiddenInfo("congtythongtin");
		$html .= "</form>";
		return $html;
		
	}
	
	function showInsertForm(){
		$html = '<form method="post" action="congty.php">';
		$html .= file_get_contents("../application/layouts/insertForm_congtythongtin.php");
		$html .= self::showHiddenInfo("congtythongtin");
		$html .='</form>';
		return $html;
	}
	
	//HIỂN THỊ THÔNG TIN ẨN
	//0: congtythongtin
	//1#: congtytaichinh
	function showHiddenInfo($type){
		return '<div><input type="hidden" name="hiddenInfo" value="'.$type.'" /></div>';		
	}
	
	//HIỂN THỊ MENU NGANG CHO CONGTY
	//0: hiển thị ở trang view -> insert
	//1: hiển thị ở trang update form
	function showMenu_Congty($flag){
		if($flag==0)
			return '<td colspan="4"><center><a href="'.Consts::URL_SHOW_INSERT_CTYTHONGTIN.'">Thêm mới</a></center></td>';
		else if($flag==1)
			return '<td colspan="4"><center><a href="'.Consts::URL_VIEW_ALL_CTYTHONGTIN.'">Xem toàn bộ</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
						<a href="'.Consts::URL_SHOW_INSERT_CTYTHONGTIN.'">Thêm mới</a></center></td>';
	}
	
	function showMenu(){
		$html = "<br/><table cellpadding='8' align='center'>
			<tr><td><a href='congty.php?ma=congtythongtin'>Thông tin cá nhân</a></td></tr>
			<tr><td><a href='congty.php?ma=congtytaichinh'>Thông tin tài chính</a></td></tr>
		</table>";
		
		return $html;
	}
}

?>
&nbsp;